package com.yh.serviceimpl;

import com.yh.javabean.Product;
import com.yh.mapper.ProductMapper;
import com.yh.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("productService")
public class ProductServiceImpl implements ProductService {

    @Autowired
    ProductMapper productMapper;


    @Override
    public List<Product> findAll() {
        return productMapper.selectAll();
    }

    @Override
    public Product findById(int id) {
        return productMapper.selectById(id);
    }

    @Override
    public boolean saveProduct(Product product) {
        return  productMapper.insert(product)==1;
    }

    @Override
    public boolean editProduct(Product product) {
        return  productMapper.update(product)==1;
    }

    @Override
    public boolean deleteProduct(int id) {
        return productMapper.deleteById(id)==1;
    }

}
